package com.ruoyi.common.core.domain.entity;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.core.domain.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import java.io.Serial;

/**
 * 字典数据表 sys_dict_data
 *
 * @author ruoyi
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@DynamicUpdate
@DynamicInsert
@Data
public class SysDictData extends BaseEntity {
	@Serial
	private static final long serialVersionUID = 1L;

	/**
	 * 字典编码
	 */
	@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "sys_dict_data_seq")
	@SequenceGenerator(name = "sys_dict_data_seq", initialValue = 1000)
	@Comment("字典编码")
	private Long dictCode;

	/**
	 * 字典排序
	 */
	@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
	@Comment("字典排序")
	@Column(length = 4)
	@ColumnDefault("0")
	private Long dictSort;

	/**
	 * 字典标签
	 */
	@Excel(name = "字典标签")
	@Comment("字典标签")
	@Column(length = 100)
	@NotBlank(message = "字典标签不能为空")
	@Size(max = 100, message = "字典标签长度不能超过100个字符")
	private String dictLabel;

	/**
	 * 字典键值
	 */
	@Excel(name = "字典键值")
	@Comment("字典键值")
	@Column(length = 100)
	@NotBlank(message = "字典键值不能为空")
	@Size(max = 100, message = "字典键值长度不能超过100个字符")
	private String dictValue;

	/**
	 * 字典类型
	 */
	@Excel(name = "字典类型")
	@Comment("字典类型")
	@Column(length = 100)
	@NotBlank(message = "字典类型不能为空")
	@Size(max = 100, message = "字典类型长度不能超过100个字符")
	private String dictType;

	/**
	 * 样式属性（其他样式扩展）
	 */
	@Comment("样式属性（其他样式扩展")
	@Column(length = 100)
	@Size(max = 100, message = "样式属性长度不能超过100个字符")
	private String cssClass;

	/**
	 * 表格字典样式
	 */
	@Comment("表格字典样式")
	@Column(length = 100)
	private String listClass;

	/**
	 * 是否默认（Y是 N否）
	 */
	@Comment("是否默认（Y是 N否）")
	@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
	@Column(length = 1)
	@ColumnDefault("'N'")
	private String isDefault;

	/**
	 * 状态（0正常 1停用）
	 */
	@Comment("状态（0正常 1停用）")
	@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
	@Column(length = 1)
	@ColumnDefault("'0'")
	private String status;

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("dictCode", getDictCode()).append("dictSort", getDictSort()).append("dictLabel", getDictLabel()).append("dictValue", getDictValue()).append("dictType", getDictType()).append("cssClass", getCssClass()).append("listClass", getListClass()).append("isDefault", getIsDefault()).append("status", getStatus()).append("createBy", getCreateBy()).append("createTime", getCreateTime()).append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime()).append("remark", getRemark()).toString();
	}
}
